package cn.edu.sjtu.se.dslab.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.action.bean.PageBean;
import cn.edu.sjtu.se.dslab.component.aadl.AADLModel;
import cn.edu.sjtu.se.dslab.dao.IAADLModelDao;
import cn.edu.sjtu.se.dslab.exception.DBException;
import cn.edu.sjtu.se.dslab.service.IAADLModelService;
import cn.edu.sjtu.se.dslab.util.Const;
@Service("aadlModelService")
@Transactional
public class AADLModelService implements IAADLModelService {

	
	@Resource(name="aadlModelDao")
	private IAADLModelDao aadlModelDao;
	@Override
	public boolean addAADLModel(AADLModel aadlModel) {
		// TODO Auto-generated method stub
		aadlModelDao.save(aadlModel);
		return true;
	}

	@Override
	public AADLModel getAADLModelById(long id) {
		// TODO Auto-generated method stub
		return aadlModelDao.queryById(id);
	}

	@Override
	public AADLModel getAADLModelByUri(String uri) {
		// TODO Auto-generated method stub
		return aadlModelDao.queryByUri(Const.URI_AADL_MODEL+":"+uri);
	}

	@Override
	public boolean updateAADLModel(AADLModel aadlModel) {
		// TODO Auto-generated method stub
		aadlModelDao.update(aadlModel);
		return true;
	}

	@Override
	public PageBean<AADLModel> getPageBean(int pageNo) throws DBException {
		// TODO Auto-generated method stub
		return aadlModelDao.queryByPageNum(pageNo);
	}

}
